import useCurrentUser from '@/utils/useCurrentUser';
import './index.less';

function Switches() {
  const {updateUser,currentUser} = useCurrentUser();
  const value = currentUser?.theme;

  return (
    <label className="switch">
      <input
        type="checkbox"
        checked={value !== 'light'}
        onChange={async () => {
          await updateUser.runAsync({
            theme: value === 'light'? 'dark' : 'light',
          });
        }}
      />
      <span className="slider"></span>
    </label>
  );
}

export default Switches;
